<!-- html -->
<template>
  <span class="span2">父组件内容：{{ parentText }}</span>
  <button class="button1" @click="changeParentText">修改内容</button>
</template>

<!-- js或ts -->
<script lang="ts">
export default {
  name: 'mittTest1Child1'
}
</script>

<!-- js或ts -->
<script setup lang="ts">
import { ref, onUnmounted } from 'vue'
import emitter from '@/assets/utils/emitter'
//数据
let parentText = ref('')
//方法
//绑定事件
emitter.on('parent-send-text', (value: any) => {
  parentText.value = value
})
//组件卸载时，解绑事件
onUnmounted(() => {
  emitter.off('parent-send-text')
})
function changeParentText() {
  parentText.value += '-'
}
</script>

<!-- 样式 -->
<style scoped></style>